#pragma strict

function each(f : function(GameObject)) {
	f(gameObject);
	
	for (var i : int = 0; i < transform.childCount; i += 1) {
		var obj : GameObject = transform.GetChild(i).gameObject;
		
		if (obj.GetComponent(Traversable) != null) {
			obj.GetComponent(Traversable).each(f);
		} else {
			f(obj);
		}
	}
}